package br.com.fsa.aplication.Util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils
{
	public static boolean validarData(String strData)
	{
		try
		{
			new SimpleDateFormat("dd/MM/yyyy HH:mm").parse(strData);
		}
		catch (ParseException e)
		{
			return (false);
		}

		return (true);
	}

	public static boolean validarData(String strDataMenor, String strDataMaior)
	{
		Date dataMenor = null;
		Date dataMaior = null;

		try
		{
			SimpleDateFormat formataData = new SimpleDateFormat(
					"dd/MM/yyyy HH:mm");

			dataMenor = formataData.parse(strDataMenor);
			dataMaior = formataData.parse(strDataMaior);

		}
		catch (ParseException e)
		{
			return (false);
		}

		return (dataMenor.before(dataMaior));
	}

	public static String converterDateParaString(Date data)
	{
		return (new SimpleDateFormat("dd/MM/yyyy HH:mm").format(data.getTime()));
	}

	public static Date converterStringToData(String data)
	{
		SimpleDateFormat formatador = new SimpleDateFormat(
				"dd/MM/yyyy HH:mm");
		try
		{
			return formatador.parse(data);
		}
		catch (ParseException ex)
		{
			throw new RuntimeException(ex);
		}
	}

	public static String getDateAtual()
	{
		SimpleDateFormat formataData = new SimpleDateFormat("dd/MM/yyyy HH:mm");
		Date dataAtual = new Date();
		return formataData.format(dataAtual);

	}
}
